#define _CRT_SECURE_NO_WARNINGS

class Solution {
public:
    int climbStairs(int n) {
        vector<int> dp(n + 1, 0);
        dp[0] = 1;
        for (int j = 0; j <= n; j++)
        {
            for (int i = 1; i <= 2; i++)
            {
                if (j >= i)
                    dp[j] += dp[j - i];
            }
        }
        return dp[n];
    }
};

class Solution {
public:
    int coinChange(vector<int>& coins, int amount) {
        vector<int>dp(amount + 1, amount + 1);
        dp[0] = 0;
        for (int i = 0; i < coins.size(); i++)
        {
            for (int j = coins[i]; j <= amount; j++)
            {
                dp[j] = min(dp[j], dp[j - coins[i]] + 1);
            }
        }
        if (dp[amount] == amount + 1)
            return -1;
        return dp[amount];
    }
};

class Solution {
public:
    int numSquares(int n) {
        vector<int>dp(n + 1, n);
        dp[0] = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = i * i; j <= n; j++)
            {
                dp[j] = min(dp[j], dp[j - i * i] + 1);
            }
        }
        return dp[n];
    }
};